From: Timo Röhling Date: Mon, 1 Sep 2025 14:51:26 +0000 (+0200) Subject: Fix build with imgui 1.92 X-Git-Tag: archive/raspbian/1.9.25+dfsg3-3+rpi1^2~28 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=5b84c1a7e7d61cce91631d16cfb36962fa7d253b;p=filament.git Fix build with imgui 1.92 Closes: #1112494 --- diff --git a/debian/patches/0023-Fix-build-with-imgui-1.92.patch b/debian/patches/0023-Fix-build-with-imgui-1.92.patch new file mode 100644 index 0000000..058f409 --- /dev/null +++ b/debian/patches/0023-Fix-build-with-imgui-1.92.patch @@ -0,0 +1,142 @@ +From: =?utf-8?q?Timo_R=C3=B6hling?= +Date: Mon, 1 Sep 2025 17:22:56 +0200 +Subject: Fix build with imgui 1.92 + +--- + libs/filagui/src/ImGuiHelper.cpp | 4 +- + libs/viewer/src/SimpleViewer.cpp | 83 +++++++++++++++++++++++++--------------- + 2 files changed, 55 insertions(+), 32 deletions(-) + +diff --git a/libs/filagui/src/ImGuiHelper.cpp b/libs/filagui/src/ImGuiHelper.cpp +index 91b2a4e..8b2d131 100644 +--- a/libs/filagui/src/ImGuiHelper.cpp ++++ b/libs/filagui/src/ImGuiHelper.cpp +@@ -217,9 +217,9 @@ void ImGuiHelper::processImGuiCommands(ImDrawData* commands, const ImGuiIO& io) + materialInstance->setScissor( pcmd.ClipRect.x, fbheight - pcmd.ClipRect.w, + (uint16_t) (pcmd.ClipRect.z - pcmd.ClipRect.x), + (uint16_t) (pcmd.ClipRect.w - pcmd.ClipRect.y)); +- if (pcmd.TextureId) { ++ if (pcmd.GetTexID()) { + TextureSampler sampler(MinFilter::LINEAR, MagFilter::LINEAR); +- materialInstance->setParameter("albedo", (Texture const*)pcmd.TextureId, sampler); ++ materialInstance->setParameter("albedo", (Texture const*)pcmd.GetTexID(), sampler); + } + rbuilder + .geometry(primIndex, RenderableManager::PrimitiveType::TRIANGLES, +diff --git a/libs/viewer/src/SimpleViewer.cpp b/libs/viewer/src/SimpleViewer.cpp +index ec78013..2e774a6 100644 +--- a/libs/viewer/src/SimpleViewer.cpp ++++ b/libs/viewer/src/SimpleViewer.cpp +@@ -94,6 +94,48 @@ static float getRangePlotValue(int series, void* data, int index) { + return ((float*) data)[series * 1024 + index]; + } + ++static ImGuiKey keyCodeToImGui(int keyCode) ++{ ++ switch (keyCode) { ++ case 8: ++ return ImGuiKey_Backspace; ++ case 9: ++ return ImGuiKey_Tab; ++ case 13: ++ return ImGuiKey_Enter; ++ case 27: ++ return ImGuiKey_Escape; ++ case 35: ++ return ImGuiKey_End; ++ case 36: ++ return ImGuiKey_Home; ++ case 37: ++ return ImGuiKey_LeftArrow; ++ case 38: ++ return ImGuiKey_UpArrow; ++ case 39: ++ return ImGuiKey_RightArrow; ++ case 40: ++ return ImGuiKey_DownArrow; ++ case 46: ++ return ImGuiKey_Delete; ++ case 65: ++ return ImGuiKey_A; ++ case 67: ++ return ImGuiKey_C; ++ case 86: ++ return ImGuiKey_V; ++ case 88: ++ return ImGuiKey_X; ++ case 89: ++ return ImGuiKey_Y; ++ case 90: ++ return ImGuiKey_Z; ++ default: ++ return ImGuiKey_None; ++ } ++} ++ + inline float3 curves(float3 v, float3 shadowGamma, float3 midPoint, float3 highlightScale) { + float3 d = 1.0f / (pow(midPoint, shadowGamma - 1.0f)); + float3 dark = pow(v, shadowGamma) * d; +@@ -426,26 +468,6 @@ void SimpleViewer::renderUserInterface(float timeStepInSeconds, View* guiView, f + + auto& io = ImGui::GetIO(); + +- // The following table uses normal ANSI codes, which is consistent with the keyCode that +- // comes from a web "keydown" event. +- io.KeyMap[ImGuiKey_Tab] = 9; +- io.KeyMap[ImGuiKey_LeftArrow] = 37; +- io.KeyMap[ImGuiKey_RightArrow] = 39; +- io.KeyMap[ImGuiKey_UpArrow] = 38; +- io.KeyMap[ImGuiKey_DownArrow] = 40; +- io.KeyMap[ImGuiKey_Home] = 36; +- io.KeyMap[ImGuiKey_End] = 35; +- io.KeyMap[ImGuiKey_Delete] = 46; +- io.KeyMap[ImGuiKey_Backspace] = 8; +- io.KeyMap[ImGuiKey_Enter] = 13; +- io.KeyMap[ImGuiKey_Escape] = 27; +- io.KeyMap[ImGuiKey_A] = 65; +- io.KeyMap[ImGuiKey_C] = 67; +- io.KeyMap[ImGuiKey_V] = 86; +- io.KeyMap[ImGuiKey_X] = 88; +- io.KeyMap[ImGuiKey_Y] = 89; +- io.KeyMap[ImGuiKey_Z] = 90; +- + // TODO: this is not the best way to handle high DPI in ImGui, but it is fine when using the + // proggy font. Users need to refresh their window when dragging between displays with + // different pixel ratios. +@@ -465,25 +487,26 @@ void SimpleViewer::mouseEvent(float mouseX, float mouseY, bool mouseButton, floa + bool control) { + if (mImGuiHelper) { + ImGuiIO& io = ImGui::GetIO(); +- io.MousePos.x = mouseX; +- io.MousePos.y = mouseY; +- io.MouseWheel += mouseWheelY; +- io.MouseDown[0] = mouseButton != 0; +- io.MouseDown[1] = false; +- io.MouseDown[2] = false; ++ io.AddMousePosEvent(mouseX, mouseY); ++ io.AddMouseWheelEvent(0, mouseWheelY); ++ io.AddMouseButtonEvent(0, mouseButton); + io.KeyCtrl = control; + } + } + + void SimpleViewer::keyDownEvent(int keyCode) { +- if (mImGuiHelper && keyCode < IM_ARRAYSIZE(ImGui::GetIO().KeysDown)) { +- ImGui::GetIO().KeysDown[keyCode] = true; ++ if (mImGuiHelper) { ++ ImGuiKey key = keyCodeToImGui(keyCode); ++ if (key != ImGuiKey_None) ++ ImGui::GetIO().AddKeyEvent(key, true); + } + } + + void SimpleViewer::keyUpEvent(int keyCode) { +- if (mImGuiHelper && keyCode < IM_ARRAYSIZE(ImGui::GetIO().KeysDown)) { +- ImGui::GetIO().KeysDown[keyCode] = false; ++ if (mImGuiHelper) { ++ ImGuiKey key = keyCodeToImGui(keyCode); ++ if (key != ImGuiKey_None) ++ ImGui::GetIO().AddKeyEvent(key, false); + } + } + diff --git a/debian/patches/series b/debian/patches/series index fd812d7..0785b14 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -20,3 +20,4 @@ 0020-Fix-shebang-to-use-Python-3.patch 0021-Do-not-build-spirv-with-Werror.patch 0022-Fixups-for-spirv.patch +0023-Fix-build-with-imgui-1.92.patch